Click Event Example

The following example illustrates how you can set up code for a Click event procedure using WithEvents and Set. Note that the object reference ce is used in place of the menu name Tools in the name of the Click event.

Private WithEvents ce As CommandBarEvents

Sub Test()

    Dim c As CommandBarControl

    Set c = Application.VBE.CommandBars("Tools").Controls(1)

    Set ce = Application.VBE.Events.CommandBarEvents(c)

End Sub

Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)

    ' Put event-handling code here

End Sub


Click Event (VBA Add-In Object Model)
Click Event

Occurs when the OnAction property of a corresponding command bar control is set.

Syntax

Sub object_Click (ByVal ctrl As Object, ByRef handled As Boolean, ByRef canceldefault As Boolean)

The Click event syntax has these named arguments:

Part	Description
ctrl	Required; Object. Specifies the object that is the source of the Click event.
handled	Required; Boolean. If True, other add-ins should handle the event. If False, the action of the command bar item has not been handled.
canceldefault	Required; Boolean. If True, default behavior is performed unless canceled by a downstream add-in. If False, default behavior is not performed unless restored by a downstream add-in.
Remarks

The Click event is specific to the CommandBarEvents object. Use a variable declared using the WithEvents keyword to receive the Click event for a CommandBar control. This variable should be set to the return value of the CommandBarEvents property of the Events object. The CommandBarEvents property takes the CommandBar control as an argument. When the CommandBar control is clicked (for the variable you declared using the WithEvents keyword), the code is executed.


ItemAdded Event (VBA Add-In Object Model)
ItemAdded Event

Occurs after a reference is added.

Syntax

Sub object_ItemAdded(ByVal item As Reference)

The required item argument specifies the item that was added.

Remarks

The ItemAdded event occurs when a Reference is added to the References collection.


ItemRemoved Event (VBA Add-In Object Model)
ItemRemoved Event

Occurs after a reference is removed from a project.

Syntax

Sub object_ItemRemoved(ByVal item As Reference)

The required item argument specifies the Reference that was removed.


Add Method (VBA Add-In Object Model)
Add Method

Adds an object to a collection.

Syntax

object.Add(component)

The Add syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
component	Required. For the LinkedWindows collection, an object. For the VBComponents collection, an enumerated constant representing a class module, a form, or a standard module.
You can use one of the following constants for the component argument:

Constant	Description
vbext_ct_ClassModule	Adds a class module to the collection.
vbext_ct_MSForm	Adds a form to the collection.
vbext_ct_StdModule	Adds a standard module to the collection.
Remarks

For the LinkedWindows collection, the Add method adds a window to the collection of currently linked windows.

Note   You can add a window that is a pane in one linked window frame to another linked window frame; the window is simply moved from one pane to the other. If the linked window frame that the window was moved from no longer contains any panes, it's destroyed.

For the VBComponents collection, the Add method creates a new standard component and adds it to the project.

For the VBComponents collection, the Add method returns a VBComponent object. For the LinkedWindows collection, the Add method returns Nothing.


AddFromFile Method (VBA Add-In Object Model)
AddFromFile Method

For the References collection, adds a reference to a project from a file. For the CodeModule object, adds the contents of a file to a module.

Syntax

object.AddFromFile(filename)

The AddFromFile syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
filename	Required. A string expression specifying the name of the file you want to add to the project or module. If the file name isn't found and a path name isn't specified, the directories searched by the Windows OpenFile function are searched.
Remarks

For the CodeModule object, the AddFromFile method inserts the contents of the file starting on the line preceding the first procedure in the code module. If the module doesn't contain procedures, AddFromFile places the contents of the file at the end of the module.


AddFromGuid Method (VBA Add-In Object Model)
AddFromGuid Method

Adds a reference to the References collection using the globally unique identifier (GUID) of the reference.

Syntax

object.AddFromGuid(guid, major, minor) As Reference

The AddFromGuid syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
guid	Required. A string expression representing the GUID of the reference.
major	Required. A Long specifying the major version number of the reference.
minor	Required. A Long specifying the minor version number of the reference.
Remarks

The AddFromGuid method searches the registry to find the reference you want to add. The GUID can be a type library, control, class identifier, and so on.


AddFromString Method (VBA Add-In Object Model)
AddFromString Method

Adds text to a module.

Syntax

object.AddFromString

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

The AddFromString method inserts the text starting on the line preceding the first procedure in the module. If the module doesn't contain procedures, AddFromString places the text at the end of the module.


Close Method (VBA Add-In Object Model)
Close Method

Closes and destroys a window.

Syntax

object.Close

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

The following types of windows respond to the Close method in different ways:

•	For a window that is a code pane, Close destroys the code pane.

•	For a window that is a designer, Close destroys the contained designer.

•	For windows that are always available on the View menu, Close hides the window.


CreateEventProc Method (VBA Add-In Object Model)
CreateEventProc Method

Creates an event procedure.

Syntax

object.CreateEventProc(eventname, objectname) As Long

The CreateEventProc syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
eventname	Required. A string expression specifying the name of the event you want to add to the module.
objectname	Required. A string expression specifying the name of the object that is the source of the event.
Remarks

Use the CreateEventProc method to create an event procedure. For example, to create an event procedure for the Click event of a Command Button control named Command1 you would use the following code, where CM represents a object of type CodeModule:

TextLocation = CM.CreateEventProc("Click", "Command1")

The CreateEventProc method returns the line at which the body of the event procedure starts. CreateEventProc fails if the arguments refer to a nonexistent event.


DeleteLines Method (VBA Add-In Object Model)
DeleteLines Method

Deletes a single line or a specified range of lines.

Syntax

object.DeleteLines (startline [, count])

The DeleteLines syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
startline	Required. A Long specifying the first line you want to delete.
count	Optional. A Long specifying the number of lines you want to delete.
Remarks

If you don't specify how many lines you want to delete, DeleteLines deletes one line.


Export Method (VBA Add-In Object Model)
Export Method

Saves a component as a separate file or files.

Syntax

object.Export(filename)

The Export syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
filename	Required. A String specifying the name of the file that you want to export the component to.
Remarks

When you use the Export method to save a component as a separate file or files, use a file name that doesn't already exist; otherwise, an error occurs.


Find Method (VBA Add-In Object Model)
Find Method

Searches the active module for a specified string.

Syntax

object.Find(target, startline, startcol, endline, endcol [, wholeword] [, matchcase] [, patternsearch]) As Boolean

The Find syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
target	Required. A String containing the text or pattern you want to find.
startline	Required. A Long specifying the line at which you want to start the search; will be set to the line of the match if one is found.
startcol	Required. A Long specifying the column at which you want to start the search; will be set to the column containing the match if one is found.
endline	Required. A Long specifying the last line of the match if one is found.
endcol	Required. A Long specifying the last line of the match if one is found.
wholeword	Optional. A Boolean value specifying whether to only match whole words. If True, only matches whole words. False is the default.
matchcase	Optional. A Boolean value specifying whether to match case. If True, the search is case sensitive. False is the default.
patternsearch	Optional. A Boolean value specifying whether or not the target string is a regular expression pattern. If True, the target string is a regular expression pattern. False is the default.
Remarks

Find returns True if a match is found and False if a match isn't found.

The matchcase and patternmatch arguments are mutually exclusive; if both arguments are passed as True, an error occurs.

The content of the Find dialog box isn't affected by the Find method.


GetSelection Method (VBA Add-In Object Model)
GetSelection Method

Returns the selection in a code pane.

Syntax

object.GetSelection(startline, startcol, endline, endcol)

The GetSelection syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
startline	Required. A Long that returns a value specifying the first line of the selection in the code pane.
startcol	Required. A Long that returns a value specifying the first column of the selection in the code pane.
endline	Required. A Long that returns a value specifying the last line of the selection in the code pane.
endcol	Required. A Long that returns a value specifying the last column of the selection in the code pane.
Remarks

When you use the GetSelection method, information is returned in output arguments. As a result, you must pass in variables because the variables will be modified to contain the information when returned.


Import Method (VBA Add-In Object Model)
Import Method

Adds a component to a project from a file; returns the newly added component.

Syntax

object.Import(filename) As VBComponent

The Import syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
filename	Required. A String specifying path and file name of the component that you want to import the component from.
Remarks

You can use the Import method to add a component, form, module, class, and so on, to your project.


InsertLines Method (VBA Add-In Object Model)
InsertLines Method

Inserts a line or lines of code at a specified location in a block of code.

Syntax

object.InsertLines(line, code)

The InsertLines syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
line	Required. A Long specifying the location at which you want to insert the code.
code	Required. A String containing the code you want to insert.
Remarks

If the text you insert using the InsertLines method is carriage return–linefeed delimited, it will be inserted as consecutive lines.


Item Method (VBA Add-In Object Model)
Item Method

Returns the indexed member of a collection.

Syntax

object.Item(index)

The Item method syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
index	Required. An expression that specifies the position of a member of the collection. If a numeric expression, index must be a number from 1 to the value of the collection's Count property. If a string expression, index must correspond to the key argument specified when the member was added to the collection.
The following table lists the collections and their corresponding key arguments for use with the Item method. The string you pass to the Item method must match the collection's key argument.

Collection	Key argument
Windows	Caption property setting
LinkedWindows	Caption property setting
CodePanes	No unique string is associated with this collection.
VBProjects	Name property setting
VBComponents	Name property setting
References	Name property setting
Properties	Name property setting
Remarks

The index argument can be a numeric value or a string containing the title of the object.


Lines Method (VBA Add-In Object Model)
Lines Method

Returns a specified line of code.

Syntax

object.Lines(startline, count) As String

The Lines syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
startline	Required. A Long specifying the first line of the code you want to return.
count	Required. A Long specifying the number of lines you want to return.
Remarks

The line numbers in a code module begin at 1.


ProcBodyLine Method (VBA Add-In Object Model)
ProcBodyLine Method

Returns the first line of a procedure.

Syntax

object.ProcBodyLine(procname, prockind) As Long

The ProcBodyLine syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
procname	Required. A String containing the name of the procedure.
prockind	Required. Specifies the kind of procedure to locate. Because property procedures can have multiple representations in the module, you must specify the kind of procedure you want to locate. All procedures other than property procedures (that is, Sub and Function procedures) use vbext_pk_Proc.
You can use one of the following constants for the prockind argument:

Constant	Description
vbext_pk_Get	Specifies a procedure that returns the value of a property.
vbext_pk_Let	Specifies a procedure that assigns a value to a property.
vbext_pk_Set	Specifies a procedure that sets a reference to an object.
vbext_pk_Proc	Specifies all procedures other than property procedures.
Remarks

The first line of a procedure is the line on which the Sub, Function, or Property statement appears.


ProcCountLines Method (VBA Add-In Object Model)
ProcCountLines Method

Returns the number of lines in the specified procedure.

Syntax

object.ProcCountLines(procname, prockind) As Long

The ProcCountLines syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
procname	Required. A String containing the name of the procedure.
prockind	Required. Specifies the kind of procedure to locate. Because property procedures can have multiple representations in the module, you must specify the kind of procedure you want to locate. All procedures other than property procedures (that is, Sub and Function procedures) use vbext_pk_Proc.
You can use one of the following constants for the prockind argument:

Constant	Description
vbext_pk_Get	Specifies a procedure that returns the value of a property.
vbext_pk_Let	Specifies a procedure that assigns a value to a property.
vbext_pk_Set	Specifies a procedure that sets a reference to an object.
vbext_pk_Proc	Specifies all procedures other than property procedures.
Remarks

The ProcCountLines method returns the count of all blank or comment lines preceding the procedure declaration and, if the procedure is the last procedure in a code module, any blank lines following the procedure.


ProcOfLine Method (VBA Add-In Object Model)
ProcOfLine Method

Returns the name of the procedure that the specified line is in.

Syntax

object.ProcOfLine(line, prockind) As String

The ProcOfLine syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
line	Required. A Long specifying the line to check.
prockind	Required. Specifies the kind of procedure to locate. Because property procedures can have multiple representations in the module, you must specify the kind of procedure you want to locate. All procedures other than property procedures (that is, Sub and Function procedures) use vbext_pk_Proc.
You can use one of the following constants for the prockind argument:

Constant	Description
vbext_pk_Get	Specifies a procedure that returns the value of a property.
vbext_pk_Let	Specifies a procedure that assigns a value to a property.
vbext_pk_Set	Specifies a procedure that sets a reference to an object.
vbext_pk_Proc	Specifies all procedures other than property procedures.
Remarks

A line is within a procedure if it's a blank line or comment line preceding the procedure declaration and, if the procedure is the last procedure in a code module, a blank line or lines following the procedure.


ProcStartLine Method (VBA Add-In Object Model)
ProcStartLine Method

Returns the line at which the specified procedure begins.

Syntax

object.ProcStartLine(procname, prockind) As Long

The ProcStartLine syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
procname	Required. A String containing the name of the procedure.
prockind	Required. Specifies the kind of procedure to locate. Because  property procedures can have multiple representations in the module, you must specify the kind of procedure you want to locate. All procedures other than property procedures (that is, Sub and Function procedures) use vbext_pk_Proc.
You can use one of the following constants for the prockind argument:

Constant	Description
vbext_pk_Get	Specifies a procedure that returns the value of a property.
vbext_pk_Let	Specifies a procedure that assigns a value to a property.
vbext_pk_Set	Specifies a procedure that sets a reference to an object.
vbext_pk_Proc	Specifies all procedures other than property procedures.
Remarks

A procedure starts at the first line below the End Sub statement of the preceding procedure. If the procedure is the first procedure, it starts at the end of the general Declarations section.


Remove Method (VBA Add-In Object Model)
Remove Method

Removes an item from a collection.

Syntax

object.Remove(component)

The Remove syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
component	Required. For the LinkedWindows collection, an object. For the References collection, a reference to a type library or a project. For the VBComponents collection, an enumerated constant representing a class module, a form, or a standard module.
Remarks

When used on the LinkedWindows collection, the Remove method removes a window from the collection of currently linked windows. The removed window becomes a floating window that has its own linked window frame.


ReplaceLine Method (VBA Add-In Object Model)
ReplaceLine Method

Replaces an existing line of code with a specified line of code.

Syntax

object.ReplaceLine(line, code)

The ReplaceLine syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
line	Required. A Long specifying the location of the line you want to replace.
code	Required. A String containing the code you want to insert.


SetFocus Method (VBA Add-In Object Model)
SetFocus Method

Moves the focus to the specified window.

Syntax

object.SetFocus

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

Use the SetFocus method on windows that are already visible.


SetSelection Method (VBA Add-In Object Model)
SetSelection Method

Sets the selection in the code pane.

Syntax

object.SetSelection(startline, startcol, endline, endcol)

The SetSelection syntax has these parts:

Part	Description
object	Required. An object expression that evaluates to an object in the Applies To list.
startline	Required. A Long specifying the first line of the selection.
startcol	Required. A Long specifying the first column of the selection.
endline	Required. A Long specifying the last line of the selection.
endcol	Required. A Long specifying the last column of the selection.


Show Method (VBA Add-In Object Model)
Show Method

Makes the specified code pane the visible code pane in its window.

Syntax

object.Show

The object placeholder is an object expression that evaluates to an object in the Applies To list.

Remarks

The Show method makes the specified code pane the pane with the focus in its window.


Add Method Example

The following example uses the Add method to add one standard module to the VBComponents collection.

Application.VBE.VBProjects(1).VBComponents.Add(vbext_ct_StdModule)


AddFromFile Method Example

The following example uses the AddFromFile method to add the contents of a file to a specified code pane.

Application.VBE.CodePanes(3).CodeModule.AddFromFile "c:\Code Files\book2.frm"


AddFromGUID Method Example

The following example uses the AddFromGUID method to add a reference to the current project, identifying the reference using the globally unique ID value of the Reference object.

Application.VBE.ActiveVBProject.References.AddFromGuid("{000204EF-0000-0000-C000-000000000046}", 5, 0)


AddFromString Method Example

The following example uses the AddFromString method to add a line, “Dim intJack As Integer,” to the specified code pane.

Application.VBE.CodePanes(3).CodeModule.AddFromString "Dim intJack As Integer"


Close Method Example

The following example uses the Close method to close a specified member of the Windows collection.

Application.VBE.Windows(9).Close


CreateEventProc Method Example

The following example uses the CreateEventProc method to create the Button_Click procedure.

Debug.Print Application.VBE.SelectVBComponents.CodeModule.CreateEventProc("Click", "Button")


DeleteLines Method Example

The following example has two steps. The first For…Next loop uses the InsertLines method to insert into CodePanes(1) 26 ever-longer initial segments of the alphabet, starting with “a.” The last line inserted is the entire alphabet.

The second For…Next loop uses the DeleteLines method to delete the odd-numbered lines. Although it seems that the second loop should simply delete every other line, note that after each deletion the lines get renumbered. Therefore the deletion is advancing by two lines at each step, one line because I is increasing by one and another line because the larger line numbers are each decreasing by one.

For I = 1 to 26

Application.VBE.SelectedVBComponent.CodeModule.InsertLines i, Mid$("abcdefghijklmnopqrstuvwxyz", 1, I)

Next

For I = 1 to 13

Application.VBE.SelectedVBComponent.CodeModule.DeleteLines I

Next


Export Method Example

The following example creates a file named test.bas and uses the Export method to copy the contents of the VBComponents(1) code module into the file.

Application.VBE.ActiveVBProject.VBComponents(1).Export("test.bas")


Find Method Example

The following example uses the Find method to verify that the specified block of lines, lines 1261 through 1279, of a particular code pane does contain the string “Tabs.Clear.”

Application.VBE.CodePanes(2).CodeModule.Find ("Tabs.Clear", 1261, 1, 1280, 1, False, False)


GetSelection Method Example

The following example returns the locations of the starting and ending points of the current selection in CodePanes(1). The last line in the example uses the GetSelection method to place the four values in the four variables.

Dim m As Long

Dim n As Long

Dim x As Long

Dim y As Long

Application.VBE.CodePanes(1).GetSelection m, n, x, y


Import Method Example

The following example uses the Import method on the VBComponents collection to copy the contents of the test.bas file into the a code module.

Application.VBE.ActiveVBProject.VBComponents.Import("test.bas")


InsertLines Method Example

The following example uses the InsertLines method to insert a line, “Option Explicit,” in the specified code pane.

Application.VBE.CodePanes(1).CodeModule.InsertLines 1, "Option Explicit"


Item Method Example

The following example contains two ways to display a specific member of the CodePanes collection, one using the Item method.

Application.VBE.CodePanes.Item(2).Show

Application.VBE.CodePanes(2).Show


Lines Method Example

The following example uses the Lines method to return a specific block of code, lines 1 through 4, in a particular code pane.

Debug.Print Application.VBE.CodePanes(1).CodeModule.Lines( 1, 4)


ProcBodyLine Method Example

The following example uses the ProcBodyLine method to return the line number of the first line of code in the specified procedure, SetupTabs, in a particular code pane.

Debug.Print Application.VBE.CodePanes(3).CodeModule.ProcBodyLine ("SetupTabs", vbext_pk_Proc)


ProcCountLines Method Example

The following example uses the ProcCountLines method to return the number of lines of code in the specified procedure, SetupTabs, in a particular code pane.

Debug.Print Application.VBE.CodePanes(3).CodeModule.ProcCountLines ("SetupTabs", vbext_pk_Proc)


ProcOfLine Method Example

The following example uses the ProcOfLine method to return the name of the procedure containing the specified line number in a particular code pane.

Debug.Print Application.VBE.CodePanes(3).CodeModule.ProcOfLine (1270, vbext_pk_Proc)


ProcStartLine Method Example

The following example uses the ProcStartLine method to return the line at which the specified procedure begins in a particular code pane.

Debug.Print Application.VBE.CodePanes(3).CodeModule.ProcStartLine ("SetupTabs", vbext_pk_Proc)


Remove Method Example

The example verifies that a particular member of the VBComponents collection is a module, and then it uses the Remove method to remove the module.

Debug.Print Application.VBE.ActiveVBProject.VBComponents(4).Name

Application.VBE.ActiveVBProject.VBComponents.Remove Application.VBE.ActiveVBProject.VBComponents(4)


ReplaceLine Method Example

The following example has two steps. The first For…Next loop uses the InsertLines method to insert into CodePanes(1) 26 ever-longer initial segments of the alphabet, starting with “a.” The last line inserted is the entire alphabet.

The second For…Next loop uses the ReplaceLine method to replace each even-numbered line with the last letter in the string that previously occupied that line. Odd-numbered lines are unchanged.

For I = 1 to 26

Application.VBE.CodePanes(1).CodeModule.InsertLines I, Mid$("abcdefghijklmnopqrstuvwxyz", 1, I)

Next I

For I = 1 to 13

Application.VBE.CodePanes(1).CodeModule.ReplaceLine 2*I, Mid$("abcdefghijklmnopqrstuvwxyz", 1, I)

Next I


SetFocus Method Example

The following example uses the SetFocus method to move the focus to a particular member of the Windows collection; that is, it makes that window behave as if you had clicked its title bar with your mouse.

Application.VBE.Windows(9).SetFocus


SetSelection Method Example

The following example uses the SetSelection method to select the text whose first character is the one immediately after the fourth character on the second line of CodePanes(1) and whose last character is the fifteenth character on the third line.

Application.VBE.CodePanes(1).SetSelection 2,4,3,15


Show Method Example

The following example uses the Show method to move the specified code pane to the foreground.

Application.VBE.CodePanes(2).Show


CodeModule Object (VBA Add-In Object Model)
CodeModule Object

Represents the code behind a component, such as a form, class, or document.

Remarks

You use the CodeModule object to modify (add, delete, or edit) the code associated with a component.

Each component is associated with one CodeModule object. However, a CodeModule object can be associated with multiple code panes.

The methods associated with the CodeModule object enable you to manipulate and return information about the code text on a line-by-line basis. For example, you can use the AddFromString method to add text to the module. AddFromString places the text just above the first procedure in the module or places the text at the end of the module if there are no procedures.

Use the Parent property to return the VBComponent object associated with a code module.


CommandBarEvents Object (VBA Add-In Object Model)
CommandBarEvents Object

Returned by the CommandBarEvents property. The CommandBarEvents object triggers an event when a control on the command bar is clicked.

Remarks

The CommandBarEvents object is returned by the CommandBarEvents property of the Events object. The object that is returned has one event in its interface, the Click event. You can handle this event using the WithEvents object declaration.


CommandBars Collection (VBA Add-In Object Model)
CommandBars Collection

Contains all of the command bars in a project, including command bars that support shortcut menus.

Remarks

Use the CommandBars collection to enable add-ins to add command bars and controls or to add controls to existing, built-in, command bars.


VBComponent Object (VBA Add-In Object Model)
VBComponent Object

Represents a component, such as a class module or standard module, contained in a project.

Remarks

Use the VBComponent object to access the code module associated with a component or to change a component's property settings.

You can use the Type property to find out what type of component the VBComponent object refers to. Use the Collection property to find out what collection the component is in.


VBComponents Collection (VBA Add-In Object Model)
VBComponents Collection

Represents the components contained in a project.

Remarks

Use the VBComponents collection to access, add, or remove components in a project. A component can be a form, module, or class. The VBComponents collection is a standard collection that can be used in a For Each block.

You can use the Parent property to return the project the VBComponents collection is in.

In Visual Basic for Applications, you can use Import method to add a component to a project from a file.


CodePane Object (VBA Add-In Object Model)
CodePane Object

Represents a code pane.

Remarks

Use the CodePane object to manipulate the position of visible text or the text selection displayed in the code pane.

You can use the Show method to make the code pane you specify visible. Use the SetSelection method to set the selection in a code pane and the GetSelection method to return the location of the selection in a code pane.


CodePanes Collection (VBA Add-In Object Model)
CodePanes Collection

Contains the active code panes in the VBE object.

Remarks

Use the CodePanes collection to access the open code panes in a project.

You can use the Count property to return the number of active code panes in a collection.


Events Object (VBA Add-In Object Model)
Events Object

Supplies properties that enable add-ins to connect to all events in Visual Basic for Applications.

Remarks

The Events object provides properties that return event source objects. Use the properties to return event source objects that notify you of changes in the Visual Basic for Applications environment.

The properties of the Events object return objects of the same type as the property name. For example, the CommandBarEvents property returns the CommandBarEvents object.


LinkedWindows Collection (VBA Add-In Object Model)
LinkedWindows Collection

Contains all linked windows in a linked window frame.

Remarks

Use the LinkedWindows collection to modify the docked and linked state of windows in the development environment.

The LinkedWindowFrame property of the Window object returns a Window object that has a valid LinkedWindows collection.

Linked window frames contain all windows that can be linked or docked. This includes all windows except code windows, designers, the Object Browser window, and the Search and Replace window.

If all the panes from one linked window frame are moved to another window, the linked window frame with no panes is destroyed. However, if all the panes are removed from the main window, it isn't destroyed.

Use the Visible property to check or set the visibility of a window.

You can use the Add method to add a window to the collection of currently linked windows. A window that is a pane in one linked window frame can be added to another linked window frame. Use the Remove method to remove a window from the collection of currently linked windows; this results in the window being unlinked or undocked.

The LinkedWindows collection is used to dock and undock windows from the main window frame.


Property Object (VBA Add-In Object Model)
Property Object

Represents the properties of an object that are visible in the Properties window for any given component.

Remarks

Use Value property of the Property object to return or set the value of a property of a component.

At a minimum, all components have a Name property. Use the Value property of the Property object to return or set the value of a property. The Value property returns a Variant of the appropriate type. If the value returned is an object, the Value property returns the Properties collection that contains Property objects representing the individual properties of the object. You can access each of the Property objects by using the Item method on the returned Properties collection.

If the value returned by the Property object is an object, you can use the Object property to set the Property object to a new object.


Properties Collection (VBA Add-In Object Model)
Properties Collection

Represents the properties of an object.

Remarks

Use the Properties collection to access the properties displayed in the Properties window. For every property listed in the Properties window, there is an object in the Properties collection.


Reference Object (VBA Add-In Object Model)
Reference Object

Represents a reference to a type library or a project.

Remarks

Use the Reference object to verify whether a reference is still valid.

The IsBroken property returns True if the reference no longer points to a valid reference. The BuiltIn property returns True if the reference is a default reference that can't be moved or removed. Use the Name property to determine if the reference you want to add or remove is the correct one.


References Collection (VBA Add-In Object Model)
References Collection

Represents the set of references in the project.

Remarks

Use the References collection to add or remove references. The References collection is the same as the set of references selected in the References dialog box.


ReferencesEvents Object (VBA Add-In Object Model)
ReferencesEvents Object

Returned by the ReferencesEvents property.

Remarks

The ReferencesEvents object is the source of events that occur when a reference is added to or removed from a project. The ItemAdded event is triggered after a reference is added to a project. The ItemRemoved event is triggered after a reference is removed from a project.


VBE Object (VBA Add-In Object Model)
VBE Object

The root object that contains all other objects and collections represented in Visual Basic for Applications.

Remarks

You can use the following collections to access the objects contained in the VBE object:

•	Use the VBProjects collection to access the collection of projects.

•	Use the Windows collection to access the collection of windows.

•	Use the CodePanes collection to access the collection of code panes.

•	Use the CommandBars collection to access the collection of command bars.

Use the Events object to access properties that enable add-ins to connect to all events in Visual Basic for Applications. The properties of the Events object return objects of the same type as the property name. For example, the CommandBarEvents property returns the CommandBarEvents object.

You can use the SelectedVBComponent property to return the active component. The active component is the component that is being tracked in the Project window. If the selected item in the Project window isn't a component, SelectedVBComponent returns Nothing.

Note   All objects in this object model have a VBE property that points to the VBE object.


VBProject Object (VBA Add-In Object Model)
VBProject Object

Represents a project.

Remarks

Use the VBProject object to set properties for the project, to access the VBComponents collection, and to access the References collection.


VBProjects Collection (VBA Add-In Object Model)
VBProjects Collection

Represents all the projects that are open in the development environment.

Remarks

Use the VBProjects collection to access specific projects in an instance of the development environment. VBProjects is a standard collection that can be used in a For Each block.


Window Object (VBA Add-In Object Model)
Window Object

Represents a window in the development environment.

Remarks

Use the Window object to show, hide, or position windows.

You can use the Close method to close a window in the Windows collection. The Close method affects different types of windows as follows:

Window	Result of using Close method
Code window	Removes the window from the Windows collection.
Designer	Removes the window from the Windows collection.
Window objects of type linked window frame	Windows become unlinked separate windows.
Note   Using the Close method with code windows and designers actually closes the window. Setting the Visible property to False hides the window but doesn't close the window. Using the Close method with development environment windows, such as the Project window or Properties window, is the same as setting the Visible property to False.

You can use the SetFocus method to move the focus to a window.

You can use the Visible property to return or set the visibility of a window.

To find out what type of window you are working with, you can use the Type property. If you have more than one window of a type, for example, multiple designers, you can use the Caption property to determine the window you're working with. You can also find the window you want to work with using the DesignerWindow property of the VBComponent object or the Window property of the CodePane object.


Windows Collection (VBA Add-In Object Model)
Windows Collection

Contains all open or permanent windows.

Remarks

Use the Windows collection to access Window objects.

The Windows collection has a fixed set of windows that are always available in the collection, such as the Project window, the Properties window, and a set of windows that represent all open code windows and designer windows. Opening a code or designer window adds a new member to the Windows collection. Closing a code or designer window removes a member from the Windows collection. Closing a permanent development environment window doesn't remove the corresponding object from this collection, but results in the window not being visible.


ActiveCodePane Property Example

The following example uses the ActiveCodePane property and TopLine properties to obtain the number of the top line in the active code pane.

Debug.Print Application.VBE.ActiveCodePane.TopLine


ActiveVBProject Property Example

The following example uses the ActiveVBProject property to return the name of the active project.

Debug.Print Application.VBE.ActiveVBProject.Name


ActiveWindow Property Example

The following example uses the ActiveWindow property to return the caption of the active window.

Debug.Print Application.VBE.ActiveWindow.Caption


BuiltIn Property Example

The following example uses the BuiltIn property to return a Boolean indicating whether or not a particular reference in the active project is built-in.

Debug.Print Application.VBE.ActiveVBProject.References(1).BuiltIn


Caption Property Example

The following example uses the Caption property to display the caption of the active window.

Debug.Print Application.VBE.ActiveWindow.Caption


CodeModule Property Example

The following example uses the CodeModule and CountOfLines properties to return the number of lines in a particular code module.

Debug.Print Application.VBE.ActiveVBProject.VBComponents(6).CodeModule.CountOfLines


CodePane Property Example

The following example uses the CodePane and TopLine properties to display the number of the top line in the code module of the selected VBComponent object.

Debug.Print Application.VBE.SelectedVBComponent.CodeModule.CodePane.TopLine


CodePanes Property Example

The following example uses the CodePanes and TopLine properties to display the line number of the top line in the specified code pane.

Debug.Print Application.VBE.CodePanes(3).TopLine


CodePaneView Property Example

The following example uses the CodePaneView property to return a value indicating whether the specified code pane is in procedure view or full module view.

Debug.Print Application.VBE.CodePanes(3).CodePaneView


Collection Property Example

The following example uses the Collection and Count properties to return the number of objects the active project contains, when viewed as a collection of objects.

Debug.Print Application.VBE.ActiveVBProject.Collection.Count


CommandBarEvents Property Example

The following example uses code including the CommandBarEvents property to support any code to handle a mouse click on a command bar.

Private WithEvents ce As CommandBarEvents

Sub Test()

    Dim c As CommandBarControl

    Set c = Application.VBE.CommandBars("Tools").Controls(1)

    Set ce = Application.VBE.Events.CommandBarEvents(c)

End Sub

Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)

    ' Put event-handling code here

End Sub


Count Property Example

The following example uses the Count property to return the number of VBComponent objects in a particular project.

Debug.Print Application.VBE.VBProjects(1).VBComponents.Count


CountOfDeclarationLines Property Example

The following example uses the CountOfDeclarationLines property to return the number of declaration lines in a particular code pane.

Debug.Print Application.VBE.CodePanes(2).CodeModule.CountOfDeclarationLines


CountOfLines Property Example

The following example uses the CountOfLines property to return the total number of lines in a particular code pane.

Application.VBE.CodePanes(2).CodeModule.CountOfLines


CountOfVisibleLines Property Example

The following example uses the CountOfVisibleLines property to return the number of lines visible at one time in a particular code pane, based on the height of the pane.

Debug.Print Application.VBE.Codepanes(3).CountOfVisibleLines


Description Property Example

The first of the following examples uses the Description property to assign a description to a particular project; the example also prints the description to verify that the assignment was successful.

The second example uses the Description property to return the descriptive names of the specified Reference objects in a particular project.

Application.VBE.VBProjects(1).Description = "Hot Sauce"

Debug.Print Application.VBE.VBProjects(1).Description

Debug.Print Application.VBE.VBProjects(1).References(1).Description

Debug.Print Application.VBE.VBProjects(1).References(2).Description


Designer Property Example

The following example uses the Designer and Count properties to return the number of controls on a form. Note that the window containing the form must be selected. The Designer object is the form itself.

Debug.Print Application.VBE.SelectVBComponent.Designer.Controls.Count


DesignerWindow Property Example

The following example uses the DesignerWindow and Visibile properties to find out whether or not a particular designer is visible. Note that the VBComponent object must be a form.

Debug.Print Application.VBE.VBProjects(1).VBComponents(1).DesignerWindow.Visible


FullPath Property Example

The following example uses the FullPath property to return the full path of the object library for the specified reference.

Debug.Print Application.VBE.ActiveVBProject.References(1).FullPath


GUID Property Example

The following example uses the GUID property to return the globally unique ID number for the specified Reference object in the specified project.

Debug.Print Application.VBE.VBProjects(1).References(1).GUID


HasOpenDesigner Property Example

The following example uses the HasOpenDesigner property to return whether or not the specified component, in this case a form, of a particular project has an open designer.

Debug.Print Application.VBE.VBProjects(1).VBComponents(1).HasOpenDesigner


Height, Width Properties Example

The following example uses the Height and Width properties to return the height and width of the specified window, in twips. These property settings change after a window is linked or docked because then they refer to the Window object to which the original window is linked or docked.

Debug.Print Application.VBE.Windows(9).Height

Debug.Print Application.VBE.Windows(9).Width


HelpContextID Property Example

The following example uses the HelpContextID property to return the context ID for the Help file corresponding to a project.

Debug.Print Application.VBE.VBProjects(1).HelpContextID


HelpFile Property Example

The following example uses the HelpFile property to assign a Help file to a project; the example verifies that the assignment was successful by printing the full path of the Help file.

Application.VBE.VBProjects(1).HelpFile = "C:\HelpStuff\veenob3.hlp"

Debug.Print Application.VBE.VBProjects(1).HelpFile


IsBroken Property Example

The following example uses the IsBroken property to return a value indicating whether or not the specified Reference object in a particular project is broken.

Debug.Print Application.VBE.vbprojects(1).References(1).IsBroken


Left, Top Properties Example

The following example uses the Left and Top properties to return the coordinates of the upper-left corner of a particular window, in twips. These property settings change after a window is linked or docked because then they refer to the Window object to which the original window is linked or docked.

Debug.Print Application.VBE.Windows(9).Left

Debug.Print Application.VBE.Windows(9).Top


MainWindow Property Example

The following example uses the MainWindow property to return the Window object representing the main window, and then prints the caption of the main window.

Debug.Print Application.VBE.MainWindow.Caption


Major Property Example

The following example uses the Major property to return the major version number of the specified Reference object in a particular project.

Debug.Print Application.VBE.VBProjects(1).References(1).Major


Minor Property Example

The following example uses the Minor property to return the minor version number of the specified Reference object in a particular project.

Debug.Print Application.VBE.VBProjects(1).References(1).Minor


Mode Property Example

The following example uses the Mode property to return the mode of the active project. The value returned is a predefined constant representing the project's mode.

Debug.Print Application.VBE.ActiveVBProject.Mode


Name Property Example

The following example uses the Name property to return the name of the specified member of the VBComponents collection in a particular project.

Debug.Print Application.VBE.VBProjects(1).VBComponents(1).Name


NumIndices Property Example

The following example uses the NumIndices property to return the number of indexes belonging to the specified property of a particular VBComponent object

Debug.Print Application.VBE.VBProjects(1).VBComponents(1).Properties(40).NumIndices


Object Property Example

The following example loads the name of an icon into the icon list for the specified object, which must be a form.

Set Application.VBE.ActiveVBProject.VBComponents(1).Properties("Icon").Object = LoadPicture("Baseball.ico")


Parent Property Example

The following example uses the Parent property to return the name of an object’s parent in the object hierarchy.

Debug.Print Application.VBE.ActiveVBProject.VBComponents.Parent.Name


Protection Property Example

The following example uses the Protection property to return a value indicating whether or not a project is protected. The value returned is a number that corresponds to a predefined constant representing the project's status.

Debug.Print Application.VBE.ActiveVBProject.Protection


ReferencesEvents Property Example

The following example uses code including the ReferencesEvents property to support event-handling code for adding or removing references.

Private WithEvents X As ReferencesEvents

Sub Test()

    Set X = Application.VBE.Events.ReferencesEvents

End Sub

Private Sub X_ItemAdded(ByVal Reference As VBIDE.Reference)

    ' Put code to support item addition here

End Sub

Private Sub X_ItemRemoved(ByVal Reference As VBIDE.Reference)

    ' Put code to support item removal here

End Sub


Saved Property Example

The following example uses the Saved property to return a Boolean value indicating whether or not the specified project has been saved in its current state.

Debug.Print Application.VBE.VBProjects(1).Saved


SelectedVBComponent Property Example

The following example uses the SelectedVBComponent property to return the selected component.

Debug.Print Application.VBE.SelectedVBComponent.Name


TopLine Property Example

The following example uses the TopLine property to return the line number of the top line in the specified code pane.

Debug.Print Application.VBE.CodePanes(3).TopLine


Type Property Example

The following example uses the Type property to return a value indicating the type of the specified member of the VBComponents collection in a particular project. The value returned is a number that corresponds to a predefined constant for one of the component object types.

Debug.Print Application.VBE.VBProjects(1).VBComponents(1).Type


Value Property Example

The following example uses the Value property to return the value of the specified property of a member of the VBComponents collection.

Debug.Print Application.VBE. ActiveVBProject.VBComponents(1).Properties("AcceptLabelsInFormulas").Value


VBE Property Example

The following example uses the VBE and Name properties to return the name of the active project.

Debug.Print Application.VBE.ActiveVBProject.Name


Version Property Example

The following example uses the Version property to return the version number of the host application.

Debug.Print Application.VBE.Version


Visible Property Example

The following example uses the Visible property to return a Boolean value indicating whether or not the specified window is visible.

Debug.Print Application.VBE.Windows(9).Visible


Window Property Example

The following example uses the Window and Caption properties to return the caption of the specified code pane.

Debug.Print Application.VBE.CodePanes(1).Window.Caption


WindowState Property Example

The following example uses the WindowState property to return the visual state of the specified window. The value returned is a number that corresponds to a predefined constant that specifies the visual state of a window.

Debug.Print Application.VBE.Windows(9).WindowState


SelectedVBComponent Property (VBA Add-In Object Model)
SelectedVBComponent Property

Returns the selected component. Read-only.

Remarks

The SelectedVBComponent property returns the selected component in the Project window. If the selected item in the Project window isn't a component, SelectedVBComponent returns Nothing.


ActiveVBProject Property (VBA Add-In Object Model)
ActiveVBProject Property

Returns the active project in the Project window. Read-only.

Remarks

The ActiveVBProject property returns the project that is selected in the Project window or the project in which the components are selected. In the latter case, the project itself isn't necessarily selected. Whether or not the project is explicitly selected, there is always an active project .


ActiveWindow Property (VBA Add-In Object Model)
ActiveWindow Property

Returns the active window in the development environment. Read-only.

Remarks

When more than one window is open in the development environment, the ActiveWindow property setting is the window with the focus. If the main window has the focus, ActiveWindow returns Nothing.


Caption Property (VBA Add-In Object Model)
Caption Property

Returns a String containing the title of the active window. Read-only.

Remarks

The title of the active window is the text displayed in the window's title bar.


CodeModule Property (VBA Add-In Object Model)
CodeModule Property

Returns an object representing the code behind the component. Read-only.

Remarks

The CodeModule property returns Nothing if the component doesn't have a code module associated with it.

Note   The CodePane object represents a visible code window. A given component can have several CodePane objects. The CodeModule object represents the code within a component. A component can only have one CodeModule object.


CodePane Property

Returns a CodePane object. Read-only.

Remarks

If a code pane exists, it becomes the active code pane, and the window that contains it becomes the active window. If a code pane doesn't exist for the module, the CodePane property creates one.


CodePaneView Property (VBA Add-In Object Model)
CodePaneView Property

Returns a value indicating whether the code pane is in Procedure view or Full Module view. Read-only.

Return Values

The CodePaneView property return values are:

Constant	Description
vbext_cv_ProcedureView	The specified code pane is in Procedure view.
vbext_cv_FullModuleView	The specified project is in Full Module view.


Collection Property (VBA Add-In Object Model)
Collection Property

Returns the collection that contains the object you are working with. Read-only.

Remarks

Most objects in this object model have either a Parent property or a Collection property that points to the object's parent object.

Use the Collection property to access the properties, methods, and controls of the collection to which the object belongs.


CommandBarEvents Property (VBA Add-In Object Model)
CommandBarEvents Property

Returns the CommandBarEvents object. Read-only.

Settings

The setting for the argument you pass to the CommandBarEvents property is:

Argument	Description
vbcontrol	Must be an object of type CommandBarControl.
Remarks

Use the CommandBarEvents property to return an event source object that triggers an event when a command bar button is clicked. The argument passed to the CommandBarEvents property is the command bar control for which the Click event will be triggered.


Count Property (VBA Add-In Object Model)
Count Property

Returns a Long containing the number of items in a collection. Read-only.


CountOfLines Property (VBA Add-In Object Model)
CountOfLines Property

Returns a Long containing the number of lines of code in a code module. Read-only.


CountOfDeclarationLines Property (VBA Add-In Object Model)
CountOfDeclarationLines Property

Returns a Long containing the number of lines of code in the Declarations section of a code module. Read-only.


CountOfVisibleLines Property (VBA Add-In Object Model)
CountOfVisibleLines Property

Returns a Long containing the number of lines visible in a code pane. Read-only.


ActiveCodePane Property (VBA Add-In Object Model)
ActiveCodePane Property

Returns the active or last active CodePane object or sets the active CodePane object. Read/write.

Remarks

You can set the ActiveCodePane property to any valid CodePane object, as shown in the following example:

Set MyApp.VBE.ActiveCodePane = MyApp.VBE.CodePanes(1)

The preceding example sets the first code pane in a collection of code panes to be the active code pane. You can also activate a code pane using the Set method.


Description Property  (VBA Add-In Object Model)
Description Property

Returns or sets a string expression containing a descriptive string associated with an object. For the VBProject object, read/write; for the Reference object, read-only.

Remarks

For the VBProject object, the Description property returns or sets a descriptive string associated with the active project.

For the Reference object, the Description property returns the descriptive name of the reference.


Designer Property (VBA Add-In Object Model)
Designer Property

Returns the object that enables you to access the design characteristics of a component.

Remarks

If the object has an open designer, the Designer property returns the open designer; otherwise a new designer is created. The designer is a characteristic of certain VBComponent objects. For example, when you create certain types of VBComponent object, a designer is created along with the object. A component can have only one designer, and it's always the same designer. The Designer property enables you to access a component-specific object. In some cases, such as in standard modules and class modules, a designer isn't created because that type of VBComponent object doesn't support a designer.

The Designer property returns Nothing if the VBComponent object doesn't have a designer.


DesignerWindow Property (VBA Add-In Object Model)
DesignerWindow Property

Returns the Window object that represents the component's designer.

Remarks

If the component supports a designer but doesn't have an open designer, accessing the DesignerWindow property creates the designer, but it isn't visible. To make the window visible, set the Window object's Visible property to True.


CodePanes Property (VBA Add-In Object Model)
CodePanes Property

Returns the collection of active CodePane objects. Read-only.


GUID Property (VBA Add-In Object Model)
GUID Property

Returns a String containing the class identifier of an object. Read-only.


HasOpenDesigner Property (VBA Add-In Object Model)
HasOpenDesigner Property

Returns a Boolean value indicating whether or not the VBComponent object has an open designer. Read-only.

Return Values

The HasOpenDesigner property returns these values:

Value	Description
True	The VBComponent object has an open Design window.
False	The VBComponent object doesn't have an open Design window.


Height Property (VBA Add-In Object Model)
Height Property

Returns or sets a Single containing the height of the window in twips. Read/write.

Remarks

Changing the Height property setting of a linked window or docked window has no effect as long as the window remains linked or docked.


HelpContextID Property (VBA Add-In Object Model)
HelpContextID Property

Returns or sets a String containing the context ID for a topic in a Microsoft Windows Help file. Read/write.


HelpFile Property (VBA Add-In Object Model)
HelpFile Property

Returns or sets a String specifying the Microsoft Windows Help file for a project. Read/write.


IndexedValue Property  (VBA Add-In Object Model)
IndexedValue Property

Returns or sets a value for a member of a property that is an indexed list or an array.

Remarks

The value returned or set by the IndexedValue property is an expression that evaluates to a type that is accepted by the object. For a property that is an indexed list or array, you must use the IndexedValue property instead of the Value property. An indexed list is a numeric expression specifying index position.

IndexedValue accepts up to 4 indices. The number of indices accepted by IndexedValue is the value returned by the NumIndices property.

The IndexedValue property is used only if the value of the NumIndices property is greater than zero. Values in indexed lists are set or returned with a single index.


IsBroken Property (VBA Add-In Object Model)
IsBroken Property

Returns a Boolean value indicating whether or not the Reference object points to a valid reference in the registry. Read-only.

Return Values

The IsBroken property returns these values:

Value	Description
True	The Reference object no longer points to a valid reference in the registry.
False	The Reference object points to a valid reference in the registry.


BuiltIn Property (VBA Add-In Object Model)
BuiltIn Property

Returns a Boolean value indicating whether or not the reference is a default reference that can't be removed. Read-only.

Return Values

The BuiltIn property returns these values:

Value	Description
True	The reference is a default reference that can't be removed.
False	The reference isn't a default reference; it can be removed.


Saved Property (VBA Add-In Object Model)
Saved Property

Returns a Boolean value indicating whether or not the object was edited since the last time it was saved. Read/write.

Return Values

The Saved property returns these values:

Value	Description
True	The object has not been edited since the last time it was saved.
False	The object has been edited since the last time it was saved.
Remarks

The SaveAs method sets the Saved property to True.

Note   If you set the Saved property to False in code, it returns False, and the object is marked as if it were edited since the last time it was saved.


Left Property (VBA Add-In Object Model)
Left Property

Returns or sets a Single containing the location of the left edge of the window on the screen in twips. Read/write.

Remarks

The value returned by the Left property depends on whether or not the window is linked or docked.

Note   Changing the Left property setting of a linked or docked window has no effect as long as the window remains linked or docked.


LinkedWindowFrame Property (VBA Add-In Object Model)
LinkedWindowFrame Property

Returns the Window object representing the frame that contains the window. Read-only.

Remarks

The LinkedWindowFrame property enables you to access the object representing the linked window frame, which has properties distinct from the window or windows it contains. If the window isn't linked, the LinkedWindowFrame property returns Nothing.


FullPath Property (VBA Add-In Object Model)
FullPath Property

Returns a String containing the path and file name of the referenced type library. Read-only.


MainWindow Property (VBA Add-In Object Model)
MainWindow Property

Returns a Window object representing the main window of the Visual Basic development environment. Read-only.

Remarks

You can use the Window object returned by the MainWindow property to add or remove docked windows. You can also use the Window object returned by the MainWindow property to maximize, minimize, hide, or restore the main window of the Visual Basic development environment.


Major Property (VBA Add-In Object Model)
Major Property

Returns a Long containing the major version number of the referenced type library. Read-only.

Remarks

The number returned by the Major property corresponds to the major version number stored in the type library to which you have set the reference.


Minor Property (VBA Add-In Object Model)
Minor Property

Returns a Long indicating the minor version number of the referenced type library. Read-only.

Remarks

The number returned by the Minor property corresponds to the minor version number stored in the type library to which you have set the reference.


Mode Property (VBA Add-In Object Model)
Mode Property

Returns a value containing the mode of the specified project. Read-only.

Return Values

The Mode property return values are:

Constant	Description
vbext_vm_Run	The specified project is in run mode.
vbext_vm_Break	The specified project is in break mode.
vbext_vm_Design	The specified project is in design mode.


Name Property (VBA Add-In Object Model)
Name Property

Returns or sets a String containing the name used in code to identify an object. For the VBProject object and the VBComponent object, read/write; for the Property object and the Reference object, read-only.

Remarks

The following table describes how the Name property setting applies to different objects.

Object	Result of Using Name Property Setting
VBProject	Returns or sets the name of the active project.
VBComponent	Returns or sets the name of the component. An error occurs if you try to set the Name property to a name already being used or an invalid name.
Property	Returns the name of the property as it appears in the Property Browser. This is the value used to index the Properties collection. The name can't be set.
Reference	Returns the name of the reference in code. The name can't be set.
The default name for new objects is the type of object plus a unique integer. For example, the first new Form object is Form1, a new Form object is Form1, and the third TextBox control you create on a form is TextBox3.

An object's Name property must start with a letter and can be a maximum of 40 characters. It can include numbers and underline (_) characters but can't include punctuation or spaces. Forms and modules can't have the same name as another public object such as Clipboard, Screen, or App. Although the Name property setting can be a keyword, property name, or the name of another object, this can create conflicts in your code.


NumIndices Property  (VBA Add-In Object Model)
NumIndices Property

Returns the number of indices on the property returned by the Property object.

Remarks

The value of the NumIndices property can be an integer from 0 – 4. For most properties, NumIndices returns 0. Conventionally indexed properties return 1. Property arrays might return 2.


Object Property  (VBA Add-In Object Model)
Object Property

Returns or sets the value of an object returned by a property. Read/write.

Remarks

If a property returns an object, you must use the Object property to return or set the value of that object.


Parent Property (VBA Add-In Object Model)
Parent Property

Returns the object or collection that contains another object or collection. Read-only.

Remarks

Most objects have either a Parent property or a Collection property that points to the object's parent object in this object model. The Collection property is used if the parent object is a collection.

Use the Parent property to access the properties, methods, and controls of an object's parent object.


Protection Property (VBA Add-In Object Model)
Protection Property

Returns a value indicating the state of protection of a project. Read-only.

Return Values

The Protection property return values are:

Constant	Description
vbext_pp_locked	The specified project is locked.
vbext_pp_none	The specified project isn't protected.


ReferencesEvents Property (VBA Add-In Object Model)
ReferencesEvents Property

Returns the ReferencesEvents object. Read-only.

Settings

The setting for the argument you pass to the ReferencesEvents property is:

Argument	Description
vbproject	If vbproject points to Nothing, the object that is returned will supply events for the References collections of all VBProject objects in the VBProjects collection. If vbproject points to a valid VBProject object, the object that is returned will supply events for only the References collection for that project.
Remarks

The ReferencesEvents property takes an argument and returns an event source object. The ReferencesEvents object is the source for events that are triggered when references are added or removed.


Top Property (VBA Add-In Object Model)
Top Property

Returns or sets a Single specifying the location of the top of the window on the screen in twips. Read/write.

Remarks

The value returned by the Top property depends on whether or not the window is docked, linked, or in docking view.

Note   Changing the Top property setting of a linked or docked window has no effect as long as the window remains linked or docked.


TopLine Property (VBA Add-In Object Model)
TopLine Property

Returns a Long specifying the line number of the line at the top of the code pane or sets the line showing at the top of the code pane. Read/write.

Remarks

Use the TopLine property to return or set the line showing at the top of the code pane. For example, if you want line 25 to be the first line showing in a code pane, set the TopLine property to 25.

The TopLine property setting must be a positive number. If the TopLine property setting is greater than the actual number of lines in the code pane, the setting will be the last line in the code pane.


Type Property (VBA Add-In Object Model)
Type Property

Returns a numeric or string value containing the type of object. Read-only.

Return Values

The Type property settings for the Window object are described in the following table:

Constant	Value	Description
vbext_wt_CodeWindow	0	Code window
vbext_wt_Designer	1	Designer
vbext_wt_Browser	2	Object Browser
vbext_wt_Watch	3	Watch pane
vbext_wt_Locals	4	Locals
vbext_wt_Immediate	5	Immediate window
vbext_wt_ProjectWindow	6	Project window
vbext_wt_PropertyWindow	7	Properties window
vbext_wt_Find	8	Find dialog box
vbext_wt_FindReplace	9	Search and Replace dialog box
vbext_wt_LinkedWindowFrame	11	Linked window frame
vbext_wt_MainWindow	12	Main window
The Type property settings for the VBComponent object are described in the following table:

Constant	Description
vbext_ct_ClassModule	Class module
vbext_ct_MSForm	Microsoft Form
vbext_ct_StdModule	Standard module
vbext_ct_Document	Document module
The Type property settings for the Reference object are described in the following table:

Constant	Description
vbext_rk_TypeLib	Type library
vbext_rk_Project	Project


Value Property (VBA Add-In Object Model)
Value Property

Returns or sets a Variant specifying the value of the property. Read/write.

Remarks

Because the Value property returns a Variant, you can access any property. To access a list, use the IndexedValue property.

If the property that the Property object represents is read/write, the Value property is read/write. If the property is read-only, attempting to set the Value property causes an error. If the property is write-only, attempting to return the Value property causes an error.

The Value property is the default property for the Property object.


VBE Property (VBA Add-In Object Model)
VBE Property

Returns the root of the VBE object. Read-only.

Remarks

All objects have a VBE property that points to the root of the VBE object.


Version Property (VBA Add-In Object Model)
Version Property

Returns a String containing the version of Visual Basic for Applications that the application is using. Read-only.

Remarks

The Version property value is a string beginning with one or two digits, a period, and two digits; the rest of the string is undefined and may contain text or numbers.


Visible Property (VBA Add-In Object Model)
Visible Property

For the Window object, returns or sets a Boolean value that specifies the visibility of a window. Read/write. For the CodePane object, returns a Boolean value that indicates whether or not the code pane is visible in the window. Read-only.

Return Values

The Visible property returns the following values:

Value	Description
True	(Default) Object is visible.
False	Object is hidden.


Width Property (VBA Add-In Object Model)
Width Property

Returns or sets a Single containing the width of the window in twips. Read/write.

Remarks

Changing the Width property setting of a linked window or docked window has no effect as long as the window remains linked or docked.


Window Property (VBA Add-In Object Model)
Window Property

Returns the window in which the code pane is displayed. Read-only.


WindowState Property (VBA Add-In Object Model)
WindowState Property

Returns or sets a numeric value specifying the visual state of the window. Read/write.

Settings

The WindowState property returns or sets the following values:

Constant	Value	Description
vbext_ws_Normal	0	(Default) Normal
vbext_ws_Minimize	1	Minimized (minimized to an icon)
vbext_ws_Maximize	2	Maximized (enlarged to maximum size)


Change Event (placeholder)


Click Event (placeholder)


DblClick Event (placeholder)


DragDrop Event (placeholder)


DragOver Event (placeholder)


KeyDown Event (placeholder)


KeyPress Event (placeholder)


KeyUp Event (placeholder)


MouseDown Event (placeholder)


MouseMove Event (placeholder)


MouseUp Event (placeholder)


OLECompleteDragEvent (placeholder)


OLEDragDrop Event (placeholder)


OLEDragOver Event (placeholder)


OLEGiveFeedback Event (placeholder)


OLESetData Event (placeholder)


OLEStartDrag Event (placeholder)


Refresh Method (placeholder)


OLEDrag Method (placeholder)


Appearance Property (placeholder)


BackColor Property (placeholder)


Caption Property (placeholder)


Enabled Property (placeholder)


Font Property (placeholder)


ForeColor Property (placeholder)


IntegralHeight Property (placeholder)


Locked Property (placeholder)


MouseIcon Property (placeholder)


MousePointer Property (placeholder)


OLEDragMode Property (placeholder)


OLEDropMode Property (placeholder)


SelLength Property (placeholder)


SelStart Property (placeholder)


SelText Property (placeholder)


Style Property (placeholder)


Text Property (placeholder)


Keyword Not Found

The keyword you've selected can't be found in Visual Basic Help. It's possible that:

•	The keyword is misspelled

•	You selected too much or too little text

•	You asked for help on a word that is not a valid Visual Basic keyword.

The easiest way to get help on a specific keyword is to position the insertion point anywhere within the keyword you want help on and press F1. You do not need to select the keyword. In fact, if you select only a portion of the keyword, or more than a single word, Help will not find what you're looking for.

To use the built-in Help search dialog box, press the Help Topics button on the toolbar.

One option to possibly find what you're looking for is to view the ReadMe file that comes with Visual Basic. This document contains information regarding last-minute changes, additions, and deletions that did not make it into the final documentation.


Left, Top Properties (Placeholder)


Height, Width Properties (Placeholder)


Tag Property (Placeholder)


ToolTipText Property (Placeholder)


Count Property (Placeholder)


Item Method (Placeholder)


Hwnd Property (Placeholder)


TabStop Property (Placeholder)


Visible Property (Placeholder)


Picture Property (placeholder)


Max, Min Properties (placeholder)


Add Method (placeholder)


Clear Method (placeholder)


Container Property (placeholder)


Controls Collection (placeholder)


Copies Property (placeholder)


DataBinding Object (placeholder)


DataBindings Collection (placeholder)


Filename Property (placeholder)


FontBold, FontItalic, FontStrikeThru Properties (placeholder)


FontName Property (placeholder)


FontSize Property (placeholder)


GetData Method (placeholder)


GetFormat Method (placeholder)


HelpFile Property (placeholder)


Item Property (placeholder)


Remove Method (placeholder)


SetData Method (placeholder)


Align Property (placeholder)


DragIcon Property (placeholder)


DragMode Property (placeholder)


HelpContextID Property (placeholder)


TabIndex Property (placeholder)


Alignment Constants (placeholder)


Border Property Constants (placeholder)


BorderStyle Constants (placeholder)


BorderStyle Property (ActiveX Controls) (placeholder)


Clear Method (ActiveX Controls) (placeholder)


Clipboard Object Constants (placeholder)


Color Constants (placeholder)


CommonDialog Control Constants (placeholder)


CommonDialog Error Constants (placeholder)


Control Constants (placeholder)


DataBindings Property (placeholder)


DDE Constants (placeholder)


Drag-and-Drop Constants (placeholder)


Drawing Constants (placeholder)


FetchVerbs Method (placeholder)


Form Constants (placeholder)


Graphics Constants (placeholder)


Grid Control Constants (placeholder)


Help Constants (placeholder)


HideSelection Property (ActiveX Controls) (placeholder)


HideSelection Property (placeholder)


Image Property (ActiveX Controls) (placeholder)


ImageList Property (ActiveX Controls) (placeholder)


Index Property (ActiveX Controls) (placeholder)


Index Property (placeholder)


Key Code Constants (placeholder)


Key Property (ActiveX Controls) (placeholder)


Menu Accelerator Constants (placeholder)


Menu Control Constants (placeholder)


Miscellaneous Constants (placeholder)


MousePointer Constants (placeholder)


OLE Container Control Constants (placeholder)


Picture Object Constants (placeholder)


Printer Object Constants (placeholder)


RasterOp Constants (placeholder)


Remove Method (ActiveX Controls) (placeholder)


ShowInTaskbar Property (placeholder)


ShowTips Property (ActiveX Controls) (placeholder)


ShowWhatsThis Method (placeholder)


Text Property (ActiveX Controls) (placeholder)


Value Property (ActiveX Controls) (placeholder)


Variant Type Constants (placeholder)


Visual Basic Constants (placeholder)


WhatsThisButton Property (placeholder)


WhatsThisHelp Property (placeholder)


WhatsThisHelpID Property (placeholder)


WhatsThisMode Method (placeholder)


Windows 95 Control Constants (placeholder)


ColIsVisible Property (placeholder)


ColPos Property (placeholder)


DataObject Object (placeholder)


DataObjectFiles Collection (placeholder)


DataSource Property (placeholder)


Drag Method (placeholder)


DrawMode Property (placeholder)


FixedAlignment Property (placeholder)


GotFocus Event (placeholder)


GridLineWidth Property (placeholder)


Index Property (Control Array) (placeholder)


LostFocus Event (placeholder)


Move Method (placeholder)


Name Property (placeholder)


Object Property (placeholder)


Parent Property (placeholder)


RowColChange Event (placeholder)


RowIsVisible Property (placeholder)


RowPos Property (placeholder)


SetFocus Method (placeholder)


ZOrder Method (placeholder)


Files Method (placeholder)


Connect Event (placeholder)


HScrollSmallChange, VScrollSmallChange Properties (placeholder)


MinHeight, MinWidth Properties (placeholder)


Property Pages Dialog Box (placeholder)


RemoteHost Property (placeholder)


RemotePort Property (placeholder)


ViewportHeight, ViewportLeft, ViewportTop, ViewportWidth Properties (placeholder)


Resync Method (Remote Data) (placeholder)


ContainedVBControls Collection (placeholder)


Member Object (placeholder)


Members Collection (placeholder)


VBComponentsEvents Object (placeholder)


VBProjectsEvents Object (placeholder)


Files Property (placeholder)


Alignment Property (placeholder)


AboutBox Method (placeholder)


Col, Row Properties (placeholder)


RowHeight Property (placeholder)


Scroll Event (placeholder)


ScrollBars Property (placeholder)


SelEndCol, SelStartCol, SelEndRow, SelStartRow Properties (placeholder)


ScrollBars Property (placeholder)


AddIn Object

The AddIn object provides information about an add-in to other add-ins.

Syntax

AddIn

Remarks

An AddIn object is created for every add-in that appears in the Vbaddin.Ini file.


AddIns Collection

Returns a collection of add-ins listed in the Vbaddin.Ini file.

Syntax

AddIns

Remarks

The AddIns collection is accessed through the VBE object. Every add-in listed in the Add-In Manager in an instance of Visual Basic has an object in the AddIns collection.

This collection replaces the ExternalObjects collection used in Visual Basic version 4.0.


CommandBar Object

The CommandBar object contains other CommandBar objects which can act as either buttons or menu commands.

Syntax

CommandBar


FileControlEvents Object

Represents all events supplied by Visual Basic which support file control.

Syntax

FileControlEvents

Remarks

The FileControlEvents object replaces the FileControl object in Visual Basic version 4.0. It works the same as before, only its events have been changed to allow multiple project support.


Member Object

The Member object represents a mixture of code-based properties and type library-based attributes of members.

Syntax

Member

Remarks

Code-based properties like Name are read-only, so the add-in must modify the code to change these properties.


Members Collection

Returns a collection of code module-level members.

Syntax

Members

Remarks

A member of a code module is an identifier that has module-level scope and which can be considered a property, method, or event of that code module.


Properties Collection

Returns the available properties of a control or component.

Syntax

Properties

Remarks

This object or collection includes all the properties that can normally be accessed at design time.

The default value for the Properties collection is determined by the Item method.

Use the Properties collection to access the properties displayed in the Properties window. For every property listed in the Properties window, there is an object in the Properties collection.


SelectedVBControls Collection

Returns a collection of currently selected controls on a component.

Syntax

SelectedVBControls

Remarks

You can use this collection to access all currently selected controls on a form. The code can step through the collection of controls or request a specific control.

This collection has the same specifications as the VBControls collection, except this collection doesn't implement the Add method. The default method for the SelectedVBControls collection is the Item method and is indexed with integers.

This collection replaces the SelectedControlTemplates collection from Visual Basic version 4.0.


SelectedVBControlsEvents Object

Represents a source of events supported by all currently selected controls.

Syntax

SelectedVBControlsEvents


VBComponentsEvents Object

Represents a source of events that occur when an object is added, removed, selected, renamed, or activated in a Visual Basic project.

Syntax

VBComponentsEvents


VBControl Object

Represents a control on a component in a project.

Syntax

VBControl

Remarks

A program can access a control through the VBForm object. Using the VBForm object, you can:

•	Access all the design time properties of a control.

•	Identify the container of the control.

•	Change the Z-order of the control.

The VBControl object replaces the ControlTemplate object from Visual Basic version 4.0.


VBControls Collection

Returns a collection all components on a form.

Syntax

VBControls

Remarks

A program can access controls through the VBControls collection. Using the VBControls collection, you can:

•	Access all the controls on a component.

•	Step through the collection of controls.

•	Return a specific control.

•	Add controls to a component.

The Item method determines the default value of the VBControls collection.

The VBControls collection replaces the ControlTemplates collection from Visual Basic version 4.0.


VBControlsEvents Object

Represents a source of events that occur when a control is added, removed, selected, renamed, or activated in a Visual Basic project.

Syntax

VBControlsEvents


VBForm Object

Returns a component in a project.

Syntax

VBForm

Remarks

The ClassName property determines the default value of the VBForm object.

The VBForm object replaces the ControlTemplate object from Visual Basic version 4.0.


VBProjectsEvents Object

Represents a source of events that occur when projects are added, removed, renamed, or activated in a Visual Basic project.

Syntax

VBProjectsEvents


AfterAddFile Event (Add-In)
AfterAddFile Event

Occurs after a component is added to the current Visual Basic project with the Add File command in the Project menu.

Syntax

Sub object_AfterAddFile(vbproject As VBProject, filetype As vbext_FileType, filename As String)

The AfterAddFile event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project in which the file was added.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was added, as listed in Settings.
filename	A string expression specifying the name of the file that was added.
Settings

The enumerated values for vbext_FileType are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.
Remarks

Visual Basic triggers this event only for files you can add from the Project menu. (That is, forms, classes, User controls, Property Pages, and modules). The AfterAddFile event does not occur if you select Add object from the Project menu. It also does not occur when an .Frx file is created for the first time, and doesn't occur twice when a form is added.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Backup the file.


AfterChangeFileName Event

Occurs after a file in the current project has been saved for the first time, or saved with a new name. It also occurs when the project is first compiled to an .Exe file, or when compiled to a new .Exe name.

Syntax

Sub object_AfterChangeFileName (vbproject As VBProject, filetype As vbext_FileType, newname As String, oldname As String)

The AfterChangeFileName event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project in which the file was changed.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was changed, as listed in Settings.
newname	A string expression specifying the new name of the file.
oldname	A string expression specifying the old name of the file.
Settings

The enumerated values for vbext_FileType are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module.
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.


AfterCloseFile Event (Add-In)
AfterCloseFile Event

Occurs after a project has been closed, either directly by the user, or by Visual Basic when the user quits the program.

Syntax

Sub object_AfterCloseFile(vbproject As VBProject, filetype As vbext_FileType, filename As String, wasdirty As Boolean)

The AfterCloseFile event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project in which the file was closed.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was closed, as listed in Settings.
filename	A string expression specifying the name of the file that was closed.
wasdirty	A Boolean expression that specifies whether changes were saved to a file prior to it being closed, as listed in Settings.
Settings

The enumerated values for vbext_FileType are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module.
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.
The settings for wasdirty are:

Setting	Description
True	The file was dirty when it was closed. (That is, the user elected to not save changes made to the file prior to closing it.)
False	The file was not dirty when it was closed (That is, the user selected to save changes made to the file prior to closing it.)
Remarks

This event can occur once for each add-in connected to the FileControl object in each project; once for each form, module, class, and control file, and once for the project file.

The AfterCloseFile event does not occur if the form is dirty and the user selects No on the Save changes to the following files dialog box. Also, this event does not occur for .Frx files when a project is closed. It occurs when the .Frm file is saved.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.

•	Compare versions of the executable (.EXE) file.


AfterRemoveFile Event (Add-In)
AfterRemoveFile Event

Occurs after a file is removed from the active Visual Basic project.

Syntax

Sub object_AfterRemoveFile(vbproject As VBProject, filetype As vbext_FileType, filename As String)

The AfterRemoveFile event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project from which the file was removed.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was removed, as listed in Settings.
filename	A string expression specifying the name of the file that was removed.
Remarks

The AfterRemoveFile event does not occur for components that are removed before they have been saved.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.


AfterWriteFile Event (Add-In)
AfterWriteFile Event

Occurs after a file is written to disk.

Syntax

Sub object_AfterWriteFile(vbproject As VBProject, filetype As vbext_FileType, filename As String, result As Integer)

The AfterWriteFile event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project to which the file was written.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was written, as listed in Settings.
filename	A string expression specifying the name of the file that was written.
result	A numeric expression that specifies the result of the write operation, as listed in Settings.
Settings

The enumerated values for vbext_FileType are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module.
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.
The settings for result are:

Value	Description
0	Write was successful.
1	Write was canceled.
2	Write failed.
Remarks

The AfterWriteFile event occurs when the binary data file associated with a component (such as an .Frx file) is saved for the first time, and occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.

•	Compare versions of the executable (.EXE) file.


BeforeLoadFile Event (Add-In)
BeforeLoadFile Event

Occurs when a component is added (not opened) to a project, or when a component's associated binary file (such as an .Frx file) is accessed.

Syntax

Sub object_BeforeLoadFile(vbproject As VBProject, filenames() As String)

The BeforeLoadFile event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project in which the file is to be loaded.
filenames	A string expression specifying the names of the files to be loaded.
Remarks

This event occurs in all add-ins that are connected to the FileControl object. This event occurs several times for a project: once for the project file; once for all the forms, modules, classes, User controls, Property Pages, and control files; and once for each of the .Frx files. This event occurs if a form file with an associated .Frx file is saved, because the .Frx is loaded when the .Frm file is saved.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.


DoGetNewFileName Event (Add-In)
DoGetNewFileName Event

Occurs whenever a Save As operation is performed on any component or project, whether manually performed from the File menu, or programmatically performed.

Syntax

Sub DoGetNewFileName(vbproject As VBProject, filetype As vbext_FileType, newname As String, oldname As String, canceldefault As Boolean)

The DoGetNewFileName event syntax has these parts:

Part	Description
vbproject	A VBProject object specifying the name of the project which will be written.
filetype	An enumerated value (vbext_FileType) specifying the type of file to be written, as listed in Settings.
newname	A string expression specifying the name of the new file. The file specification must be relative to the current LastUsedPath property or a fully qualified filename.
oldname	A string expression specifying the old name of the file.
canceldefault	A Boolean expression that determines the default Visual Basic action, as described in Settings.
Settings

The enumerated values for vbext_FileType are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module.
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.
The settings for canceldefault are:

Setting	Description
True	Stops triggering this event for any subsequent add-ins connected to the FileControl object. If newname is a zero-length string ("") when canceldefault is set to True, the event is canceled; otherwise, the name entered in newname is used as the new filename.
False	Continues triggering this event for subsequent add-ins connected to the FileControl object. If no add-in sets canceldefault to True, the Save File As or Make .Exe dialog box is displayed with the string you entered in newname selected.
Remarks

If the canceldefault parameter is set to True, the Save File As dialog box is not displayed. If canceldefault is set to False, the Save File As dialog box displays. If more than one add-ins is connected, and canceldefault is set to True at any time during a Save As operation, the Save File As dialog box will not display for any of the add-ins until the next Save As operation is performed.

The newname argument is initially set to the same value as oldname, but any add-in that receives this event can change it. One way to do this is through a custom user interface where you obtain the new name of the file and set newname to the user's selection. However, if canceldefault is True (meaning that a previous add-in has set it to True), you shouldn't set newname again.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.


IDTExtensibility Interface

The IDTExtensibility interface contains methods that Visual Basic calls when an add-in is connected to it, whether through the Add-In Manager, or some other manner.

The IDTExtensibility interface contains pre-configured procedure templates (which includes their parameter lists) that you need to manage add-ins in Visual Basic.

Syntax

Implements IDTExtensiblity

Remarks

The usage of interfaces is new to Visual Basic 5.0. Interfaces enable you to choose a pre-configured procedure template from a module's Procedure drop down list, eliminating parameter list entry errors and allowing you to program your applications a bit faster.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, simply select it from the drop down box.

The IDTExtensiblity interface currently contains four methods:

•	OnAddinsUpdate Method

•	OnConnection Method

•	OnDisconnection Method

•	OnStartupComplete Method

While these are methods to the IDTExtensibility interface, to you as a Visual Basic programmer, though, they act and behave like events. In other words, when an add-in is connected to Visual Basic, the OnConnection method is called automatically, similar to an event firing. When it is disconnected, the OnDisconnection method is called automatically, and so forth.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.


ItemActivated Event

Occurs when a component is double-clicked in the Project window, and when a project is single-clicked in a project window when there are multiple projects loaded in the IDE.

Syntax

Sub object_ItemActivated(vbcomponent As VBComponent)

Sub object_ItemActivated(vbproject As VBProject)

The ItemActivated event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbcomponent	A VBComponent object specifying the name of the component that was double-clicked.
vbproject	A VBProject object specifying the name of the project which was double-clicked.
Remarks

The ItemActivated event does not occur when a component is double-clicked in the Project window.


ItemAdded Event

Occurs after a project, control, or component is added to the current project.

Syntax

Sub object_ItemAdded (vbproject As VBProject)

Sub object_ItemAdded (vbcomponent As VBComponent)

Sub object_ItemAdded (vbcontrol As VBControl)

The ItemAdded event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project that was loaded.
vbcomponent	A VBComponent object specifying the name of the component that was loaded.
vbcontrol	A VBControl object specifying the name of the control that was loaded.


ItemRemoved Event

Occurs after a project, control, or component is removed from the current project.

Syntax

Sub object_ItemRemoved (vbcontrol As VBControl)

Sub object_ItemRemoved (vbproject As VBProject)

Sub object_ItemRemoved (vbcomponent As VBComponent)

The ItemRemoved event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project that was removed.
vbcomponent	A VBComponent object specifying the name of the component that was removed.
vbcontrol	A VBControl or SelectedVBControl object specifying the name of the component that was removed.


ItemRenamed Event

Occurs after a project, control, or component is renamed in the current project.

Syntax

Sub object_ItemRenamed (vbproject As VBProject)

Sub object_ItemRenamed (vbcomponent As VBComponent)

Sub object_ItemRenamed (vbcontrol As VBControl)

The ItemRenamed event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A VBProject object specifying the name of the project that was renamed.
vbcomponent	A VBComponent object specifying the name of the component that was renamed.
vbcontrol	A VBControl object specifying the name of the control that was renamed.


ItemSelected Event

Occurs when a component in the Project window or an open designer-window is clicked.

Syntax

Sub object_ItemSelected (vbcomponent As VBComponent)

The ItemSelected event syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbcomponent	A VBComponent object specifying the name of the component that was selected.


RequestChangeFileName Event

Occurs after specifying a new filename for a component or project, and the name change is completed.

Syntax

Sub RequestChangeFileName(vbproject As VBProject, filetype As vbext_FileType, newname As String, oldname As String, cancel As Boolean)

The RequestChangeFileName event syntax has these parts:

Part	Description
vbproject	A VBProject object specifying the name of the project the new file will be added to.
filetype	An enumerated value (vbext_FileType) specifying the type of file that was written, as listed in Settings.
newname	A string expression specifying the name given to the renamed file.
oldname	A string expression specifying containing the name of the file before it was renamed.
cancel	A Boolean expression that determines the default Visual Basic action, as described in Settings.
Settings

The settings for filetype are:

Constant	Value	Description
vbext_ft_Form	0	File type is a form.
vbext_ft_Module	1	File type is a basic module.
vbext_ft_Class	2	File type is a class module.
vbext_ft_Project	3	File type is a project.
vbext_ft_Exe	4	File type is an executable file.
vbext_ft_Res	6	File type is a resource file.
vbext_ft_UserControl	7	File type is a User control.
vbext_ft_PropertyPage	8	File type is a Property Page.
vbext_ft_DocObject	9	File type is a User Document.
vbext_ft_Binary	10	File type is a binary file.
vbext_ft_GroupProject	11	File type is a group project.
vbext_ft_Designer	12	File type is a designer object.
The settings for cancel are:

Setting	Description
True	Cancel the renaming of the file. This event won't be triggered for any subsequent add-ins connected to the FileControl object.
False	Continue triggering this event for subsequent add-ins connected to the FileControl object.
Remarks

This event allows all the add-ins to examine the new filename that is proposed to be added to the project, and decide whether to accept or cancel the name change.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.


RequestWriteFile Event

Occurs prior to saving any project component with unsaved changes.

Syntax

Sub RequestWriteFile(vbproject As VBProject, filename As String, cancel As Boolean)

The RequestWriteFile event syntax has these parts:

Part	Description
vbproject	A VBProject object specifying the name of the project containing the component.
filename	A string expression containing the name of the file to be saved.
cancel	A Boolean expression used as a flag to cancel the action, as described in Settings.
Settings

The settings for cancel are:

Setting	Description
True	Does not write the file to disk. This event is not triggered for any subsequent add-ins connected to the FileControl object.
False	Continues triggering this event for subsequent add-ins connected to the FileControl object.
Remarks

The RequestWriteFile event occurs once for each saved component, and once for each associated binary data file (such as .Frx or .Pgx files).

This event allows add-ins to prepare the specified file for writing. For example, you could use it to enable an add-in to check out a file from a source code control project prior to writing to it.

This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:

•	Log information about the event.

•	Update information about the file.

•	Back up the file.


Activate Method

Causes the currently selected component in the project window to be activated as if it were double-clicked.

Syntax

object.Activate

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Add Method (Add-In)
Add Method

•	ContainedVBControls collection: Adds a new VBControl object to the ContainedVBControls collection.

•	VBControls collection: Adds a new VBControl object to the VBControls collection.

•	VBProjects collection: adds a new, empty project to the set of projects in the VBProjects collection.

Syntax

object.Add (progid As String, [relativevbcontrol As VBControl] [before As Boolean]) As VBControl

object.Add (projecttype As vbext_ProjectType, [exclusive As Boolean]) As VBProject

The Add method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
progid	Required. A string expression specifying the ProgID of the component to be added.
relativevbcontrol	Optional. An existing VBControl object specifying the point where the new component is to be inserted.
before	Optional. Default = False. A Boolean expression specifying whether the new VBControl is to be placed before or after the relativevbcontrol.
projecttype	Required. A VBProject object specifying the type of the new project. For a list of kinds of projects, see the Kind property.
exclusive	Optional. Default = False. A Boolean expression specifying whether a new project is added to an existing set of projects, or added as the only project.
Remarks

If the exclusive parameter is specified as True, then the existing group project is closed and the new project becomes the only project in the collection.


AddCustom Method

Returns a VBComponent object, or creates a new custom component and adds it to the project.

Syntax

object.AddCustom (ByVal progid As String) As VBComponent

The AddCustom method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
progid	Required. The ProgID of the custom component to be created.


AddFile Method

Returns the newly added component.

Syntax

object.AddFile (ByVal pathname As String, [relateddocument As Boolean]) As VBComponent

The AddFile method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
pathname	Required. A string expression specifying the path and filename of the file to open as a template.
relateddocument	Optional (for text files only). Default = False. A Boolean expression specifying whether the file is to be treated as a standard module or a document. If set to True, then the file added is treated as a document file.
Remarks

Files that are normally Visual Basic project components, such as forms, cause an error if the relateddocument parameter is set to True. The relateddocument parameter is required only when adding text files that can be treated as either standard modules or documents.


AddFromFile Method

Adds or opens a project or group project.

Syntax

object.AddFromFile (ByVal pathname As String, [exclusive As Boolean]) As VBNewProjects

The AddFromFile method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
pathname	Required. A string expression specifying the path to the file to use as the template.
exclusive	Optional. Default = False. A Boolean expression. If set to True, then the existing group project is closed and the new project is created as the only open project.
Remarks

If the file is a group project file and exclusive is set to False, then all projects in that group project are added to the current group project. If the file is a group project file and exclusive is set to True, then the current group project is replaced by the specified one.


AddFromTemplate Method

•	VBComponents collection: Returns the newly created component, and creates a new component from a template.

•	VBProjects collection: Returns a collection of all projects added as a result of a call to this method, or creates a new project using an existing project as a template.

Syntax

object.AddFromTemplate (filename As String) As VBComponent

object.AddFromTemplate (ByVal pathname As String, [exclusive As Boolean]) As VBNewProjects

The AddFromTemplate method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
filename	Required. A string expression specifying the path and filename of the file to open as a template.
exclusive	Optional. Default = False. A Boolean expression. If set to True, then the existing group project is closed and the new project is created as the only open project.
pathname	Required. A string expression specifying the path to the file to use as the template.
Remarks

If the file type referenced is a group project file, and exclusive is set to False, then all projects in that file are created as templates and added to the current set of open projects. If exclusive is set to True, however, the current group project is closed and a new group project created, and all projects within the group project template are created as project templates. The object returned by the method is Nothing.

New project or projects are given the usual default names.


AddToolboxProgID Method

Places the control or embedded component in the toolbox and adds a control reference to the project.

Syntax

object.AddToolboxProgID (ByVal progid As String, [filename As String])

The AddToolboxProgID method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
progid	Required. A string expression specifying the programmatic identifier (ProgID) of the compound document object to add to the Visual Basic toolbox. Either a version-independent or version-dependent ProgID can be used. If a version-independent progid is specified, the most recent version is used. If the compound document object has an associated type library, this type library is referenced as well.
filename	Optional. A string expression specifying the filename of the desired type library to be added to Visual Basic. A complete pathname can be used, but if the file isn't found, the directories searched by the Windows OpenFile function are searched, even if a complete pathname is specified.


Item Method (Add-In)
Item Method

Returns an item from the specified collection by either name or index.

•	AddIns collection:

•	ContainedVBControls collection:

•	Members collection:

•	SelectedVBControls collection:

•	VBControls collection:

•	VBNewProjects collection:

Syntax

object.Item (index)

object.Item (collectionindex, [controlindex]) As VBControl

object.Item (var) As Member

The Item method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
index	Required. A variant expression specifying the name or index in the collection of the object to be accessed.
collectionindex	Required. A numeric expression specifying the index
controlindex	Optional.
var	Required.
Remarks

There is no guarantee that a given index number for a collection will always point to the same item, because items may be added or deleted from the collection. Using index numbers for the collection is useful only when iterating through the whole collection and no items are added or deleted during the iteration.


MakeCompiledFile Method

Causes the current project to be written as an Exe, Dll, or control, depending on project type.

Syntax

object.MakeCompiledFile

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


OnAddinsUpdate Method

Occurs automatically when changes to the Vbaddin.Ini file are saved.

Syntax

object.IDTExtensibility_OnAddinsUpdate (custom() As Variant)

The OnAddinsUpdate method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
custom()	An array of variant expressions to hold user-defined data.
Remarks

This method is part of the IDTExtensibility interface, which you should implement in the class that provides your connection object.

Important   Don't directly enter the syntax given above. Instead, use the Implements statement to generate the appropriate method template for the interface. To do this, in the Declarations section of the Class module that provides your add-in's connection object, enter:

Implements IDTExtensibility

After adding this line, you can select IDTExtensibility from the module's Object drop down box. Select each method from the Procedure drop down to get the procedure template shown above in Syntax. Notice that the necessary code is automatically added to the Class module.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, select the method from the Procedure drop down box.

Note   While the OnAddinsUpdate method is a method to the IDTExtensibility interface, to you as a Visual Basic programmer it acts and behaves like an event. In other words, when changes made to the Vbaddin.Ini file are saved, any code in the OnAddinsUpdate method automatically occurs, just as if it were an event procedure.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.


OnConnection Method

Occurs when an add-in is connected to the Visual Basic IDE, either through the Add-In Manager dialog box or another add-in.

Syntax

object. IDTExtensibility_OnConnection (vbinst As Object, connectmode As vbext_ConnectMode, addininst As AddIn, custom() As Variant)

The OnConnection method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbinst	An object representing the instance of the current Visual Basic session.
connectmode	An enumerated value of type vbext_ConnectMode, as specified in Settings.
addininst	An AddIn object representing the instance of the add-in.
custom()	An array of variant expressions to hold user-defined data.
Settings

The settings for connectmode (vbext_ConnectMode) are:

Constant	Value	Description
vbext_cm_AfterStartup	0	Add-in was started after the initial Open Project dialog box was shown.
vbext_cm_Startup	1	Add-in was started before the initial Open Project dialog box was shown.
vbext_cm_External	2	Add-in was started externally by another program or component.
Remarks

This method is part of the IDTExtensibility interface, which you should implement in the class that provides your connection object.

Important   Don't directly enter the syntax given above. Instead, use the Implements statement to generate the appropriate method template for the interface. To do this, in the Declarations section of the Class module that provides your add-in's connection object, enter:

Implements IDTExtensibility

After adding this line, you can then select IDTExtensibility from the module's Object drop down box. Select each method from the Procedure drop down to get the procedure template shown above in Syntax. Notice that the necessary code is automatically added to the Class module.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, select the method from the Procedure drop down box.

Note   While the OnConnection method is a method to the IDTExtensibility interface, to you as a Visual Basic programmer it acts and behaves like an event. In other words, when an add-in is connected to the Visual Basic IDE, either through the Add-In Manager dialog box or another add-in, any code in the OnConnection method automatically occurs, just as if it were an event procedure.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.


OnDisconnection Method

Occurs when an add-in is disconnected from the Visual Basic IDE, either programmatically or through the Add-In Manager dialog box.

Syntax

object. IDTExtensibility_OnDisconnection (removemode As vbext_DisconnectMode, custom()As Variant)

The OnDisconnection method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
removemode	An enumerated value of type vbext_DisconnectMode, as specified in Settings.
custom()	An array of variant expressions to hold user-defined data.
Settings

The settings for removemode (vbext_ConnectMode) are:

Constant	Value	Description
vbext_dm_HostShutdown	0	Add-in was removed by the add-in's host being closed.
vbext_dm_UserClosed	1	Add-in was removed by the user closing it.
Remarks

This method is part of the IDTExtensibility interface, which you should implement in the class that provides your connection object.

Important   Don't directly enter the syntax given above. Instead, use the Implements statement to generate the appropriate method template for the interface. To do this, in the Declarations section of the Class module that provides your add-in's connection object, enter:

Implements IDTExtensibility

After adding this line, you can then select IDTExtensibility from the module's Object drop down box. Select each method from the Procedure drop down to get the procedure template shown above in Syntax. Notice that the necessary code is automatically added to the Class module.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, select the method from the Procedure drop down box.

Note   While the OnDisconnection method is a method to the IDTExtensibility interface, to you as a Visual Basic programmer it acts and behaves like an event. In other words, when an add-in is disconnected from the Visual Basic IDE, either programmatically or through the Add-In Manager dialog box, any code in the OnDisconnection method automatically occurs, just as if it were an event procedure.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.


OnStartupComplete Method

Occurs when the startup of the Visual Basic IDE is complete.

Syntax

object. IDTExtensibility_OnStartupComplete (custom() As Variant)

The OnStartupComplete method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
custom()	An array of variant expressions to hold user-defined data.
Remarks

This method is part of the IDTExtensibility interface, which you should implement in the class that provides your connection object.

Important   Don't directly enter the syntax given above. Instead, use the Implements statement to generate the appropriate method template for the interface. To do this, in the Declarations section of the Class module that provides your add-in's connection object, enter:

Implements IDTExtensibility

After adding this line, you can then select IDTExtensibility from the module's Object drop down box. Select each method from the Procedure drop down to get the procedure template shown above in Syntax. Notice that the necessary code is automatically added to the Class module.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, select the method from the Procedure drop down box.

Note   While the OnStartupComplete method is a method to the IDTExtensibility interface, to you as a Visual Basic programmer it acts and behaves like an event. In other words, when the startup of the Visual Basic IDE is complete, any code in the OnStartupComplete method automatically occurs, just as if it were an event procedure.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.


ReadProperty Function (Add-In)
ReadProperty Method

Returns a string from the specified user-defined section and key in the project's .Vbp or component file.

•	VBComponent object:

•	VBProject object:

Syntax

object.ReadProperty (key As String) As String

object.ReadProperty (section As String, key As String) As String

The ReadProperty function syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
section	A string expressioncontaining the name of the section where the key is found.
key	A string expressioncontaining the name of the key to return.
Remarks

If the section or key area in the file is empty or doesn't exist, you'll get run-time error 5: "Illegal function call."


Reload Method (Add-In)
Reload Method

Reloads the specified component from disk, discarding any unsaved changes.

Syntax

object.Reload

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Cursor position, code window and form visibility are not affected by the Reload method. Reload doesn't change the setting which indicates whether the project was edited since the last time it was saved.


Remove Method (Visual Basic Extensibility)

Removes an item from a collection.

Syntax

object.Remove (index)

The Item method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
index	Required. A variant expression specifying the name or index in the collection of the object to be accessed.
Remarks

For the LinkedWindows collection, removes a window from the collection of currently linked windows. The removed window becomes a floating window that has its own LinkedWindowFrame. This is the point at which LinkedWindowFrame windows are created.

For the VBProjects collection, removes the specified project from the collection.

For the References collection, removes the specified reference from the collection.


SaveAs Method

Saves a component or project to a given location using a new filename.

Syntax

object.SaveAs (newfilename As String)

The SaveAs method syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
newfilename	Required. A string expression specifying the new filename for the component to be saved.
Remarks

If a new path name is given, it is used. Otherwise, the old path name is used. If the new filename is invalid or refers to a read-only file, an error occurs.

When a form is saved, newfilename specifies the new name of the form file itself. The .Frx file, if applicable, is saved automatically with an .Frx extension.

Note   Successfully invoking this method causes the associated events from the FileControl object to be invoked.


Update Method

Refreshes the contents of the AddIns collection from the add-ins listed in the Vbaddin.ini file in the same manner as if the user had opened the Add-In Manager dialog box.

Syntax

object.Update

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

All add-ins listed in the Vbaddin.ini file must be registered ActiveX components in the Registry before they can be used in Visual Basic.


BuildFileName Property

Returns the executable or DLL name that will be used when the project is built.

Syntax

object.BuildFileName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


CanPaste Property

Returns a boolean value indicating whether or not the Clipboard contains appropriate information (that is, controls) for pasting to the form.

Syntax

object.CanPaste

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


CodeLocation Property

Returns the line location in the code module where the member is defined.

Syntax

object.CodeLocation [= propkind ]

The CodeLocation property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
propkind	An enumerated value of vbext_PropertyKind, as described in Settings.
Settings

The settings for vbext_PropertyKind are:

Constant	Value	Description
vbext_PropertyGet	1	(Default) Returns the code location for the Get element of the property.
vbext_PropertyLet	2	Returns the code location for the Let element of the property.
vbext_PropertySet	3	Returns the code location for the Set element of the property.


CompatibleOLEServer Property

Returns or sets the compatible ActiveX component of this project.

Syntax

object.CompatibleOLEServer

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


ControlObject Property

Returns a reference to an instance of the design-time IDispatch pointer provided by the control. If there isn’t one, this property returns Nothing.

Syntax

object.ControlObject

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

For example, the Toolbar control provides an object through a Property Page's ControlObject property to set the number of buttons.


ControlType Property

Returns the type of run-time window that a control creates.

Syntax

object.ControlType As vbext_ControlType

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The settings for vbext_ControlType are:

Constant	Value	Description
vbext_ct_Light	1	(Default) No hWnd at run-time.
vbext_ct_Standard	2	hWnd at run-time.
vbext_ct_Container	3	hWnd at run-time, and can contain other controls.


DisplayModel Property

Returns or sets the display model used by the system.

Syntax

object.DisplayModel As vbext_VBADisplayModel

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Settings

The settings for vbext_VBADisplayModel are:

Constant	Value	Description
vbext_dm_SDI	0	(Default) Display model is SDI (Single Document Interface).
vbext_dm_MDI	1	Display model is MDI (Multiple Document Interface).


FileControlEvents Property

Returns an event object of type FileControlEvents.

Syntax

object.FileControlEvents

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


FileCount Property (Add-In)
FileCount Property

Returns the number of files associated with a given component.

Syntax

object.FileCount

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The primary use for FileCount is to alert you to whether a component has an associated .Frx file.

For most components, this property setting is 1, but it can be greater. For example, if an .FRX file is associated with a form file, the FileCount property setting is 2.


FileName Property

Returns the full path name of the group project file.

Syntax

object.Filename

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Group projects have no name other than the file name.

The path name returned will always be provided as an absolute path (for example, "c:\projects\myproject.vbp"), even if it is shown as a relative path in Visual Basic (such as "..\projects").


FileNames Property (Add-In)
FileNames Property

Returns the current path name(s) in which the component will be stored.

Syntax

object.FileNames(index)

The FileNames property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
index	A long integer specifying the location of the filename in the indexed string to return.
Remarks

The path name returned will always be provided as an absolute path (for example, "c:\projects\myproject.vbp"), even if it is shown as a relative path in Visual Basic (such as "..\projects").

The number of entries in the indexed string is determined by the FileCount property setting. The indexed string for classes and modules contains only one filename, while the indexed string for forms contains both the .Frm and .Frx filename for the form. The values of the filenames are updated when the SaveAs method is invoked on the object.


FullName Property

Returns the full path name of the Visual Basic IDE. (That is, the path where vb5.exe was run.)

Syntax

object.FullName

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The path name returned is always provided as an absolute path (for example, "c:\projects\myproject.vbp"), even if it is shown as a relative path in Visual Basic (such as "..\projects").


IconState Property (Add-In)
IconState Property

Returns or sets the source code control icon (or "glyph") for the project in the project window, indicating its status.

Syntax

object.IconState [= value ]

The IconState property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
value	A long integer or constant that determines the file status, as described in Settings.
Settings

The settings for value are:

Constant	Value	Description
vbextSCCStatusNotControlled	0	File is not under source code control.
vbextSCCStatusControlled	1	File is under source code control.
vbextSCCStatusCheckedOut	2	File is checked out to current user.
vbextSCCStatusOutOther	4	File is checked out to another user.
vbextSCCStatusOutOfDate	32	The file is not the most recent.
vbextSCCStatusShared	512	File is shared between projects.
Remarks

The IconState property can be logically OR'ed together to form combined states.


IndexedValue Property

Returns or sets a value in an indexed list or an array.

Syntax

object.IndexedValue [index1, index2,][ index3,] [index4]][ = value]

The IndexedValue property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
indexn	A numeric expression specifying index position. IndexedValue accepts up to four indices. The number of indices accepted by IndexedValue is the value for the same property returned by the NumIndices property.
value	An expression that evaluates to a type acceptable to the control.
Remarks

If the property is a list (as indicated by NumIndices), then IndexedValue returns the element of the list specified by the index parameters.

IndexedValue is used only if the value of the NumIndices property is greater than zero. Values in indexed lists, as in the List property of a ListBox control, are set or returned with a single index.


InSelection Property

Returns or assigns a control's selection state.

Syntax

object.InSelection

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

If the InSelection property of a control contained within another control is set to True, then any controls not within that control (or any controls within other controls) will be unselected.


LastUsedPath Property

Returns or sets the last path used for the file dialog boxes used in Visual Basic, such as the Open Project dialog box.

Syntax

object.LastUsedPath ([pathname As String])

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

The LastUsedPath property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
pathname	(Optional) A string containing the last path name used for a file dialog box.


NumIndices Property

Returns the number of indices on the property returned by the Property object, which is the number of indices required to access the value.

Syntax

object.NumIndices

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The value of NumIndices can have a value from 0 to 4. For normal properties, as in the ForeColor property, NumIndices returns 0. Conventionally indexed properties, such as the List property of a ListBox control, return 1. Property arrays might return a 2.


ProgID Property

Returns the ProgID (programmatic ID) for the control represented by the VBControl object.

Syntax

object.ProgID

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


ReadOnlyMode Property (Add-In)
ReadOnlyMode Property

Returns or sets a value that determines how the Visual Basic development environment interacts with read-only files.

Syntax

object.ReadOnlyMode [= value]

The ReadOnlyMode property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
value	A long integer or constant that determines the project status, as described in Settings.
Settings

The settings for value are:

Value	Description
1	Strict. Remove File and Add File commands are not available if the project file is read-only on the disk. Windows and forms can be moved, but changes will not be saved. For files which are also read-only on disk, the Code Window is read-only; controls cannot be added or removed, control positions are locked, and custom Properties dialog boxes are disabled.
0	Lenient. Modifications can be made to code, forms, and the project if files are read-only, but changes can't be saved back to the files.


Scope Property

Returns whether a member is public, private, or friend.

Syntax

object.Scope

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


SelectedVBControlsEvents Property

Returns all events supported by the controls currently selected on a form.

Syntax

object.SelectedVBControlsEvents (vbproject As Variant)

The SelectedVBControlsEvents property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A variant expression specifying the project which contains the form and controls.
Remarks

Returns an event object of type SelectedVBControlsEvents. This event is sourced from a VBForm.


StartMode Property

Returns or sets the start mode of the project.

Syntax

object.StartMode

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

Returns RunMode if code is currently executing, BreakMode if there is code on the stack but not running, and DesignMode otherwise.


StartProject Property

Returns or sets the project that will start when the user selects Start from the Run menu, or presses the F5 key.

Syntax

object.StartProject

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


StartUpObject Property

Returns or sets the startup component for the project.

Syntax

object.StartUpObject

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The value that is returned is a variant that contains either an enumerated value of type vbext_StartupObject, or a VBComponent object that represents the startup object.

The StartUpObject property settings for vbext_StartUpObject are:

Constant	Value	Description
vbext_so_SubMain	0	Startup object is the sub Main.
vbext_so_None	1	There is no startup object.
Remarks

Only visual at run-time project items can be the startup object.


Static Property

Returns whether the referenced variable or method is declared as Static.

Syntax

object.Static

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


TemplatePath Property

Returns the full pathname where Visual Basic stores template files.

Syntax

object.TemplatePath

The object placeholder represents an object expression that evaluates to an object in the Applies To list.


Type Property

Returns the type of the currently selected member or project.

Syntax

object.Type

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Return Values

The Type property settings for the Member object (vbext_MemberType) are:

Constant	Value	Description
vbext_mt_Method	1	Member is a method.
vbext_mt_Property	2	Member is a property.
vbext_mt_Variable	3	Member is a variable.
vbext_mt_Event	4	Member is an event.
vbext_mt_Enum	5	Member is an enumerated value.
vbext_mt_Const	6	Member is a constant.
vbext_mt_EventSink	7	Member is an event sink.
The Type property settings for the Project object (vbext_ProjectType) are:

Constant	Value	Description
vbext_pt_StandardExe	1	Project type is Standard Exe.
vbext_pt_ActiveXExe	2	Project type is ActiveX Exe.
vbext_pt_ActiveXDll	3	Project type is ActiveX Dll.
vbext_pt_ActiveXControl	4	Project type is ActiveX control.


VBComponentsEvents Property

Returns an event object of type VBComponentsEvents.

Syntax

object.VBComponentsEvents (vbproject As vbProject)

The VBComponentsEvents property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	An object of type vbProject which specifies the project which contains the components.


VBControlsEvents Property

Returns all events supported by the controls on a form.

Syntax

object.VBControlsEvents(vbproject As Variant, vbform As VBForm)

The VBControlsEvents property syntax has these parts:

Part	Description
object	An object expression that evaluates to an object in the Applies To list.
vbproject	A variant expression specifying the project which contains the controls.
vbform	The form containing the controls.
Remarks

Returns an event object of type VBControlsEvents. This event is sourced from a VBForm or a control on a VBForm that can contain controls.


VBProjectsEvents Property

Returns an event object of type VBProjectsEvents.

Syntax

object.VBProjectsEvents

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

This is identical to using the VBProjects collection events.